package com.wuyb.controller;

import com.wuyb.pojo.entity.BaseResponse;
import com.wuyb.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 角色权限控制器
 *
 * @Author: wyb
 * @Date: 2024/01/08/19:04
 * @Description:
 */
@RestController
@RequestMapping("/role")
@Api(tags = "权限")
@Slf4j
public class RoleController {

    @Resource
    private RoleService roleService;

    @PreAuthorize("@SGExpressionRoot.hasAuthority('role')")
    @ApiOperation("查看管理员权限列表(隐藏权限除外)")
    @GetMapping()
    public BaseResponse<?> getAllRole() {
        log.info("Get:/role 查看管理员权限列表。");
        return roleService.selectAllRole();
    }
}
